package com.naton.mydemo.model.api;

import com.naton.common.network.download.CommDownloadHelper;
import com.naton.common.network.download.DownloadListener;

/**
 * @time: 2022/1/22
 * @author: lifuling
 * @version: v1.0
 * @file_desc: 包装基本的下载帮助类  配置baseUrl
 */
public class FileDownloadHelper {

    private static FileDownloadHelper instance;
    private String mBaseUrl;

    private FileDownloadHelper(String baseUrl){
        this.mBaseUrl = baseUrl;
    }

    public static FileDownloadHelper getInstance(){
        if (instance == null){
            synchronized (FileDownloadHelper.class){
                if (instance == null){
                    instance = new FileDownloadHelper("");
                }
            }
        }
        return instance;
    }

    /**
     * 文件下载
     * @param url
     * @param tempDir
     * @param fileName
     * @param downloadListener
     */
    public void downloadFile(String url , String tempDir , String fileName , DownloadListener downloadListener){
        CommDownloadHelper commDownloadHelper = new CommDownloadHelper(mBaseUrl,downloadListener);
        commDownloadHelper.downloadFile(url , tempDir , fileName);
    }
}
